﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="paringpohikiri_vastus", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(ParingpohikiriVastus))]
    public class ParingpohikiriVastusSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IParingpohikiriVastus clazz;
        
        public ParingpohikiriVastusSerializer(IParingpohikiriVastus clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("kuupaev");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Kuupaev))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("sisu");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "base64Binary");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdBase64Binary(((byte[])(clazz.Sisu))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="kuupaev") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paringpohikiri_vastus>kuupaev");
                }
                clazz.Kuupaev = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("kuupaev")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>paringpohikiri_vastus>kuupaev", Reader.LocalName);
            }
            if (Reader.LocalName=="sisu") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paringpohikiri_vastus>sisu");
                }
                clazz.Sisu = new global::Xtee.Core.Schema.XsdBase64Binary(Reader.ReadElementString("sisu")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>paringpohikiri_vastus>sisu", Reader.LocalName);
            }
        }
    }
}
